from pages.base_page import BasePage


class ShoeCalendarPage(BasePage):
    date_filter_button = '//*[@resource-id="cool.dingstock.mobile:id/iv_date"]'
    filter_confirm = '//*[@resource-id="cool.dingstock.mobile:id/home_pop_tv_confirm_filter"]'
    first_month = '//*[@resource-id="cool.dingstock.mobile:id/tv_date"]'
    text_className = 'android.widget.TextView'

    def filter_date(self):
        """筛选发售日期为下一个月"""
        self.click_xpath(self.date_filter_button)
        self.swipe_position((0.508, 0.81), (0.506, 0.738))
        self.click_xpath(self.filter_confirm)

    def get_first_date(self):
        """第一个发售的日期"""
        return self.get_first_classname_element_text(self.text_className, 0)

    def get_first_month(self):
        """当前筛选月份"""
        return self.get_xpath_text(self.first_month)[0]
